﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using F_MODEL;
using F_BLL;
namespace MvcApplication1.Controllers
{
    public class UserAddrController : zyl_LoginController
    {
        UserAddrBll bll = new UserAddrBll();
        //
        // GET: /UserAddr/
        /// <summary>
        /// 添加方法
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="UserTel"></param>
        /// <param name="Contry1"></param>
        /// <param name="city1"></param>
        /// <param name="Addr1"></param>
        /// <returns></returns>
        [HttpGet]
        public int UserAddrAdd( string UserName, string UserTel, string Contry1, string city1, string Addr1,int st)
        {
           
            F_MODEL.UserAddrModel umodel = new UserAddrModel();
            umodel.UserAddrName = UserName;
            umodel.UserAddrTel = UserTel;
            umodel.UserAddrCon = Contry1;
            umodel.UserAddrCity = city1;
            umodel.UserAddrAdr = Addr1;
            umodel.UserAddrState = st;
            UserInfo u = new UserInfo();
            u = mod();
            umodel.Userid = u.userId;
            if (bll.UserAddrAdd(umodel) == true)
            {
                return 1;
            }
            else
            {
                return 0;
            }

        }
        /// <summary>
        /// 查询地址
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<UserAddrModel> UserAddrSel()
        {
            UserInfo m = new UserInfo();
            int id = 0;
            m = mod();
            if(m!=null)
            id = m.userId;
          List<UserAddrModel> list=  bll.UserAddrSel(id);
          return list;
        }

        /// <summary>
        /// 后台审核信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<UserAddrModel> MailsUserSel(int mailStatus)
        {
            List<UserAddrModel> list = bll.MaiUserlSel(mailStatus);
            return list;
        }
        /// <summary>
        /// 删除默认地址
        /// </summary>
        /// <param name="UserNameId"></param>
        /// <returns></returns>
         [HttpGet]
        public int UserDel(int UserNameId)
        {
            if (bll.UserAddrDel(UserNameId) > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
         /// <summary>
         /// 添加运单信息
         /// </summary>
         /// <param name="UserName"></param>
         /// <param name="UserTel"></param>
         /// <param name="Contry1"></param>
         /// <param name="city1"></param>
         /// <param name="Addr1"></param>
         /// <returns></returns>
         [HttpGet]
         public int MailAdd(string mailId, string sendUser, string receiveUser, string dweight, decimal predictPrice, string goodsImg,string types1)
         {

             F_MODEL.UserAddrModel umodel = new UserAddrModel();
             umodel.mailId = mailId;
             umodel.types1 = types1;
             umodel.sendUser =  sendUser;
             umodel.receiveUser = receiveUser;
             umodel.dweight = dweight;
             umodel.predictPrice =  predictPrice;
             umodel.goodsImg = goodsImg;
              umodel.mailIsDel = 0;
              umodel.mailTimeSpan = DateTime.Now; ;
             umodel.mailStatus = 0 ;
             umodel.stationId = 1;
             umodel.ParCeId=1;
            UserInfo u = mod();
            if (u != null)
            {
                umodel.Userid = u.userId;
            }
            else {
                umodel.Userid = 1;
            }  
             if (bll.MailsAdd(umodel) == true)
             {
                 return 1;
             }
             else
             {
                 return 0;
             }

         }
        /// <summary>
        /// 寄件信息
        /// </summary>
        /// <returns></returns>
         [HttpGet]
         public List<UserAddrModel> MailSel()
         {
             UserInfo m = new UserInfo();
             m = mod();
             int id = m.userId;
             List<UserAddrModel> list = bll.MailSel(id);
             return list;
         }
         [HttpGet]
         public List<UserAddrModel> GetState()
         {

             UserInfo m = new UserInfo();
             m = mod();
             int userid = m.userId;
             return bll.SelectState(userid);
         }
         [HttpGet]
         public int UpdateState(string mailId)
         {
             UserInfo m = new UserInfo();
             m = mod();
             int userid = m.userId;
             return bll.UpdateState(userid, int.Parse(mailId));
         }
        /// <summary>
        /// 包裹信息
        /// </summary>
        /// <param name="mailId"></param>
        /// <returns></returns>
         [HttpGet]
         public List<UserAddrModel> MaildaihuoSel(int mailId)
         {
             List<UserAddrModel> list = bll.MaildaihuoSel(mailId);
             return list;
         }

         /// <summary>
         /// 明细信息
         /// </summary>
         /// <param name="mailId"></param>
         /// <returns></returns>
         [HttpGet]
         public List<UserAddrModel> MingxiSel(int mailId)
         {
             List<UserAddrModel> list = bll.MingxiSel(mailId);
             return list;
         }
         /// <summary>
         /// 修改寄件物品状态
         /// </summary>
         /// <param name="UserNameId"></param>
         /// <returns></returns>
         [HttpGet]
         public int MailsUserUpd(int mailStatus,int mailId)
         {
             if (bll.UserMailUpd(mailStatus, mailId) > 0)
             {
                 return 1;
             }
             else
             {
                 return 0;
             }
         }
         /// <summary>
         /// 全部订单
         /// </summary>
         /// <param name="mailId"></param>
         /// <returns></returns>
         [HttpGet]
         public List<UserAddrModel> Pro_quanbu()
         {
             List<UserAddrModel> list = bll.Pro_quanbu();
             return list;
         }


    }
}
